/**
 * Copyright 2012 Alfredo "Rainbowbreeze" Morresi
 * 
 * This file is part of Eureka! project.
 * 
 * Eureka! is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * Eureka! is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with Eureka!. If not, see http://www.gnu.org/licenses/.
 */
package it.rainbowbreeze.eureka.data;

import it.rainbowbreeze.eureka.common.AppEnv;
import it.rainbowbreeze.eureka.domain.QualityDataPoint;
import it.rainbowbreeze.eureka.util.DataProvider;
import it.rainbowbreeze.eureka.util.TestHelper;
import it.rainbowbreeze.libs.data.RainbowBaseContentProviderDaoTest;
import android.content.Context;

/**
 * @author Alfredo "Rainbowbreeze" Morresi
 *
 */
public class QualityDataPointDaoTest
        extends RainbowBaseContentProviderDaoTest<EurekaProvider, QualityDataPointDao, QualityDataPoint>
{
    // ------------------------------------------ Private Fields


    // -------------------------------------------- Constructors
    public QualityDataPointDaoTest() {
        super(EurekaProvider.class, EurekaContract.AUTHORITY);
    }

    // ------------------------------------------ Public Methods
    public void testGetPointsAround() {
        //creates some test points
        QualityDataPoint item;
        
        item = new QualityDataPoint();
        item.setAcquisitionTimestamp(1332610836); //TODO
        item.setCategoryId(10);
        item.setLatitude(41000000);
        item.setLongitude(12000000);
        item.setMeasureId(1);
        item.setRadius(1000);
        item.setReadingTimestamp(1334100000);
        item.setReferringRadius(2000);
        item.setScore(3);
        item.setValue(123.4);
        long item1Id = insertAndVerifyItem(item);
        
        item = new QualityDataPoint();
        item.setAcquisitionTimestamp(1332610836); //TODO
        item.setCategoryId(10);
        item.setLatitude(41002000);
        item.setLongitude(12002000);
        item.setMeasureId(1);
        item.setRadius(500);
        item.setReadingTimestamp(1334100000);
        item.setReferringRadius(2000);
        item.setScore(1);
        item.setValue(20.2);
        long item2Id = insertAndVerifyItem(item);
        
        item = new QualityDataPoint();
        item.setAcquisitionTimestamp(1332610836); //TODO
        item.setCategoryId(10);
        item.setLatitude(41002000);
        item.setLongitude(12001000);
        item.setMeasureId(1);
        item.setRadius(700);
        item.setReadingTimestamp(1334100000);
        item.setReferringRadius(2000);
        item.setScore(2);
        item.setValue(53.4);
        long item3Id = insertAndVerifyItem(item);
        
        //TODO test has to be finished!
    }
    

    // ----------------------------------------- Private Methods

    /* (non-Javadoc)
     * @see it.rainbowbreeze.libs.data.RainbowBaseContentProviderDaoTest#getMockContext(android.content.Context)
     */
    @Override
    protected Context getMockContext(Context context) {
        return TestHelper.getMockContext(context);
    }

    /* (non-Javadoc)
     * @see it.rainbowbreeze.libs.data.RainbowBaseContentProviderDaoTest#initEnvironment(android.content.Context)
     */
    @Override
    protected boolean initEnvironment(Context context) {
        return TestHelper.init(context);
    }

    /* (non-Javadoc)
     * @see it.rainbowbreeze.libs.data.RainbowBaseContentProviderDaoTest#getDaoIntance(android.content.Context)
     */
    @Override
    protected QualityDataPointDao getDaoIntance(Context context) {
        return AppEnv.i(context).getQualityDataPointDao();
    }

    /* (non-Javadoc)
     * @see it.rainbowbreeze.libs.data.RainbowBaseContentProviderDaoTest#createTestItem1()
     */
    @Override
    protected QualityDataPoint createTestItem1() {
        return DataProvider.createQualityDataPoint1();
    }

    /* (non-Javadoc)
     * @see it.rainbowbreeze.libs.data.RainbowBaseContentProviderDaoTest#createTestItem2()
     */
    @Override
    protected QualityDataPoint createTestItem2() {
        return DataProvider.createQualityDataPoint2();
    }

    /* (non-Javadoc)
     * @see it.rainbowbreeze.libs.data.RainbowBaseContentProviderDaoTest#createTestItem3()
     */
    @Override
    protected QualityDataPoint createTestItem3() {
        return DataProvider.createQualityDataPoint3();
    }

    /* (non-Javadoc)
     * @see it.rainbowbreeze.libs.data.RainbowBaseContentProviderDaoTest#compareItem(it.rainbowbreeze.libs.data.RainbowSettableId, it.rainbowbreeze.libs.data.RainbowSettableId)
     */
    @Override
    protected void compareItem(QualityDataPoint expected, QualityDataPoint actual) {
        assertEquals("Wrong acquisition timestamp", expected.getAcquisitionTimestamp(), actual.getAcquisitionTimestamp());
        assertEquals("Wrong category id", expected.getCategoryId(), actual.getCategoryId());
        assertEquals("Wrong id", expected.getId(), actual.getId());
        assertEquals("Wrong latitude", expected.getLatitude(), actual.getLatitude());
        assertEquals("Wrong longitude", expected.getLongitude(), actual.getLongitude());
        assertEquals("Wrong measure id", expected.getMeasureId(), actual.getMeasureId());
        assertEquals("Wrong radius", expected.getRadius(), actual.getRadius());
        assertEquals("Wrong reading timestamp", expected.getReadingTimestamp(), actual.getReadingTimestamp());
        assertEquals("Wrong referring radius", expected.getReferringRadius(), actual.getReferringRadius());
        assertEquals("Wrong score", expected.getScore(), actual.getScore());
        assertEquals("Wrong value", expected.getValue(), actual.getValue());
    }
}
